<template>
  <a-modal :maskClosable="false"
    :title="title"
    :width="1280"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">

    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="8" :sm="8">
            <a-form-item label="指标类型">
              <j-dict-select-tag
                placeholder="请选择指标类型"
                dictCode="healthy_data"
                v-model="queryParam.keyCode"
              />
            </a-form-item>
          </a-col>
          <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
           <a-col :md="6" :sm="24">
               <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
               <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
           </a-col>
        </span>
        </a-row>
      </a-form>
    </div>

    <a-spin :spinning="confirmLoading">
      <a-table
        style="margin-top: 10px"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
      </a-table>
    </a-spin>
  </a-modal>
</template>

<script>
import { httpAction, putAction, getAction, postAction } from '@api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { pushIfNotExist } from '@/utils/util'
import EmployeeDialog from '@views/his/dialog/EmployeeDialog'

export default {
  name: 'HHisInterviewPlanLogModal',
  mixins: [JeecgListMixin],
  components: {
    EmployeeDialog
  },
  data() {
    return {
      title: '操作',
      visible: false,
      queryParam: { planType: '3' },
      disableMixinCreated: true,
      layout: {
        labelCol: { span: 6 },
        wrapperCol: { span: 14 }
      },
      confirmLoading: false,
      url: {
        list: '/his/patient/healthy/data/dy/list'
      },
      columns: [
        {
          title: '录入时间',
          align: 'center',
          dataIndex: 'createTime',
          width: 180
        },
        {
          title: '数据来源',
          align: 'center',
          dataIndex: 'inputSource',
          width: 120,
          customRender: function (text, record, index) {
            return "心血管测评";
          }
        },
        {
          title: '指标类型',
          align: 'center',
          dataIndex: 'keyName',
          width: 180
        },
        {
          title: '数据值',
          align: 'left',
          width: 500,
          dataIndex: 'itemList',
          customRender: function (text, record, index) {
            let textStr = '';
            console.log(record.itemList)
            record.itemList.forEach((item, index)=>{
              textStr+=item.indexName+"："+item.dataValue+ '\n'
            });

            const answer = textStr.split('\n')
            return answer.map((item) => {
              return <li>{item}</li>
            })
          },
        },
        {
          title: '是否达标',
          align: 'center',
          dataIndex: 'resultStatus',
          width: 120,
          customRender: (text, record, index) => {
            if (text == '1') {
              return '达标'
            } else {
              return '不达标'
            }
          }
        }
      ]
    }
  },
  created() {

  },

  methods: {
    view(record) {
      const that = this
      that.visible = true
      that.queryParam.startTime = record.createTime
      that.queryParam.endTime = record.effectiveTime
      that.queryParam.patientId = record.patientId
      that.loadData()
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      const that = this
      that.close()
    },
    handleCancel() {
      this.close()
    }
  }
}
</script>

<style scoped>

</style>